/**
 * 存储cookie数据
 * @param {string} key 键
 * @param {string} val 数据
 * @param {number} s 时间/秒
 */
function setcookie(key,val,s) {
    if (typeof val === "object") val = JSON.stringify(val);
    const d = new Date();
    d.setTime(d.getTime() - 1000 * 60 * 60 *8 + 1000 * 1 * s);
    document.cookie = `${key}=${val}; expires=${d}`;
}

/**
 * 移出cookie数据
 * @param {string} key 键
 */
function removecookie(key){
    setcookie(key,null, -1);
}

/**
 * 获取cookie数据
 * @param {string} key 键
 * @returns 
 */
function getcookie(key){
    let arr = document.cookie.split(";");
    for ( let i = 0; i < arr.length; i++) {
        let temp = arr[i].split("=");
        if (temp[0] === key) {
            return temp[1];
        }
    }
    return null;
}